import Vue from 'vue'
import VueRouter from 'vue-router'
import Reg from '../views/Reg/Reg.vue'
import Login from '../views/Login/Login.vue'
import Main from '../views/Main/Main.vue'

import Home from '@/views/Menus/Home/Home.vue'
import UserInfo from '@/views/Menus/User/UserInfo.vue'
import UserAvatar from '@/views/Menus/User/UserAvatar.vue'
import UserPwd from '@/views/Menus/User/UserPwd.vue'
import ArtCate from '@/views/Menus/Article/ArtCate.vue'
Vue.use(VueRouter)
import ArtList from '@/views/Menus/Article/ArtList.vue'

const routes = [
  {
   path:'/reg',
   name:'reg',
   component:Reg
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/',
    name: 'main',
    component: Main,
    redirect: '/home' ,
    children:[
      // 配置主页,Home
      {
        path: 'home',
        name: 'home',
        component: Home
      },
       // 配置个人中心,基本资料
      {
        path: '/user-info',
        name: 'userInfo',
        component: UserInfo
      },
       // 配置个人中心,更换头像
      {
        path: '/user-avatar',
        name: 'UserAvatar',
        component: UserAvatar
      },
      // 配置个人中心,重置密码
      {
        path: '/user-pwd',
        name: 'UserPwd',
        component: UserPwd
      },
      // 配置文章管理,文章分类的接口
      {
        path: '/art-cate',
        name: 'artcate',
        component: ArtCate
      },
      {
        path: '/art-list',
        name: 'ArtList',
        component: ArtList
      },
    ]
  },
]

const router = new VueRouter({
  routes
})

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}


export default router
